/* $RCSFile: ADNDynQueue.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/CRMWrapper3/DynEntities/ADNDynQueue.cs $
 * $log$
 * Revision 19 2010/10/02 14:01:49  christian.surieux
 *   Corrected a bug in allmost everyADNDyn file for PrimaryFieldVualue
 * Revision 6 2010/08/06 19:56:33  christian.surieux
 *   Added Log to All cs files
 */

using System;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using CrmSdk;

namespace AddonNice.CRMWrapper
{
	public class ADNDynQueue : DynEntity
	{
        protected class Ftor: DFactor
        {
            public Ftor() : base(CrmStr.queue)
            {}

            public override Type DynType
            { get { return typeof(ADNDynQueue); } }

            public override string DynTypename
            {   get{ return CrmStr.queue;}}

            public override DynEntity Build()
            {   return new ADNDynQueue();}

            public override DynEntity Build(CRMWrapperBase w, InternalDynamicEntity dEntity, PropertyDescriptorCollection wproperties)
            {   return new ADNDynQueue(w, dEntity, wproperties, null);}

            public override DynEntity Build(CRMWrapperBase w, string PrimaryFieldValue)
            {   return new ADNDynQueue(w,PrimaryFieldValue);}

            public override DynEntity Build(CRMWrapperBase w,Guid PrimaryKeyValue)
            {   return new ADNDynQueue(w,PrimaryKeyValue);}
        }

        static ADNDynQueue(){new Ftor();} 

        /// <summary>
        /// No owner but a PrimaryUserid
        /// </summary>
        public override bool HasOwnerProperty
        {
            get
            {
                return false;
            }
        }

        public override bool HasBusinessUnitProperty
        {
            get
            {
                return true;
            }
        }

        public ADNDynQueue(): base()
		{}

        public ADNDynQueue(CRMWrapperBase w, string PrimaryFiedlValue)
			: base(w, CrmStr.queue)
		{
            if ( PrimaryFiedlValue != string.Empty )
                name    =   PrimaryFiedlValue;
		}

		public ADNDynQueue(CRMWrapperBase w, Guid CrmId)
			: base(w,CrmStr.queue, CrmId)
		{}

		public ADNDynQueue(CRMWrapperBase w, InternalDynamicEntity e)
			: base(w,CrmStr.queue,e,null,null)
		{}

		public ADNDynQueue(CRMWrapperBase w, InternalDynamicEntity e,PropertyDescriptorCollection prop,InternalColumnSet s)
			: base(w,CrmStr.queue,e,prop,s)
		{}

        public ADNDynQueue(ResetWrapperHandler fn, string PrimaryFiedlValue)
			: base(fn, CrmStr.queue)
		{
            if ( PrimaryFiedlValue != string.Empty )
                name    =   PrimaryFiedlValue;
		}

		public ADNDynQueue(ResetWrapperHandler fn, Guid CrmId)
			: base(fn,CrmStr.queue, CrmId)
		{}

		public ADNDynQueue(ResetWrapperHandler fn, InternalDynamicEntity e)
			: base(fn,CrmStr.queue,e,null,null)
		{}

		public ADNDynQueue(ResetWrapperHandler fn, InternalDynamicEntity e,PropertyDescriptorCollection prop,InternalColumnSet s)
			: base(fn,CrmStr.queue,e,prop,s)
		{}

		/// <summary>
		/// Crm Key
		/// </summary>
        [CrmDynAttribute(CrmStr.queue)]
        public Guid queueid
		{
			get
			{
				return KeyPropertyValue(CrmStr.queueid);
			}
			set
			{
				AddKeyProperty(CrmStr.queueid, value);
			}
		}

        protected override void SetCrmIdProperty(Guid crmId)
        {
           if ( !dicProperty.ContainsKey(CrmStr.queueid) || KeyPropertyValue(CrmStr.queueid) != crmId )
                queueid   =   crmId;
        }
        
        public override string PrimaryFieldName
        {
            get
            {
               return CrmStr.name;
            }
           set
           {}
        }

        /// <summary>
        /// Value contained in the PrimaryField for the DynEntity or empty if no PrimaryField
        /// </summary>
        public override string PrimaryFieldStringValue
        {
            get
            {
                return name;
            }
            set
            {
                name =   value;
            }
        }

        public override Guid PrimaryKeyGuidValue
        {
           get
           {
                return queueid;
           }
           set
           {
               queueid    =   value;
           }
        }

        /// <summary>
        /// Gets or sets the subject of the annotation. 
        /// </summary>
        [CrmDynAttribute(CrmStr.queue)]
        public override string name 
        {
            get
            {
                return StringPropertyValue(CrmStr.name);
            }
            set
            {
                AddStringProperty(CrmStr.name,value);
            }
        }

        /// <summary>
        /// Gets or sets the mimetype of the annotation attached file. 
        /// </summary>
        [CrmDynAttribute(CrmStr.queue)]
        public string description 
        {
            get
            {
                return StringPropertyValue(CrmStr.description);
            }
            set
            {
                AddStringProperty(CrmStr.description,value);
            }
        }
        
        /// <summary>
        /// Gets or sets the e-mail address associated with the queue. 
        /// </summary>
        [CrmDynAttribute(CrmStr.queue)]
        public string emailaddress 
        {
            get
            {
                return StringPropertyValue(CrmStr.emailaddress);
            }
            set
            {
                AddStringProperty(CrmStr.emailaddress,value);
            }
        }
 
        /// <summary>
        /// Gets or sets the e-mail password for the e-mail address associated with the queue. 
        /// </summary>
        [CrmDynAttribute(CrmStr.queue)]
        public string emailpassword 
        {
            get
            {
                return StringPropertyValue(CrmStr.emailpassword);
            }
            set
            {
                AddStringProperty(CrmStr.emailpassword,value);
            }
        }
 
        /// <summary>
        /// Gets or sets the e-mail user name for the e-mail address associated with the queue. 
        /// </summary>
        [CrmDynAttribute(CrmStr.queue)]
        public string emailusername 
        {
            get
            {
                return StringPropertyValue(CrmStr.emailusername);
            }
            set
            {
                AddStringProperty(CrmStr.emailusername,value);
            }
        }

        /// <summary>
        ///  Gets or sets the value that indicates if a user wants to specify e-mail credentials for the e-mail router. 
        /// </summary>
        [CrmDynAttribute(CrmStr.queue)]
        public bool allowemailcredentials
        {
            get 
            {
                return BooleanPropertyValue(CrmStr.allowemailcredentials);
            }
            set 
            {
                AddBooleanProperty(CrmStr.allowemailcredentials,value);
            }
        }

        /// <summary>
        /// Gets or sets the value that indicates if the queue should ignore unsolicited e-mail. 
        /// </summary>
        [CrmDynAttribute(CrmStr.queue)]
        public bool ignoreunsolicitedemail
        {
            get 
            {
                return BooleanPropertyValue(CrmStr.ignoreunsolicitedemail);
            }
            set 
            {
                AddBooleanProperty(CrmStr.ignoreunsolicitedemail,value);
            }
        }

        /// <summary>
        /// Gets or sets the incoming e-mail delivery method for the queue. 
        /// None 
        /// E-mail Router
        /// Forward Mailbox
        /// </summary>
        [CrmDynAttribute(CrmStr.queue)]
        public int incomingemaildeliverymethod
		{
			get
			{
				return PicklistPropertyIntValue(CrmStr.incomingemaildeliverymethod);
			}
			set
			{
				AddPicklistProperty(CrmStr.incomingemaildeliverymethod,value);
			}
		}

        public string incomingemaildeliverymethodLabel
        {
            get
            {
                if ( ContainsKey(CrmStr.incomingemaildeliverymethod) )
                    return PicklistPropertyLabelValue(CrmStr.incomingemaildeliverymethod);
                return string.Empty;
            }
        }
        
        /// <summary>
        /// Gets or sets the incoming e-mail filtering method. 
        /// All e-mail messages 
        /// E-mail messages in response to CRM e-mail
        /// E-mail messages from CRM Leads, Contacts and Accounts
        /// </summary>
        [CrmDynAttribute(CrmStr.queue)]
        public int incomingemailfilteringmethod
		{
			get
			{
				return PicklistPropertyIntValue(CrmStr.incomingemailfilteringmethod);
			}
			set
			{
				AddPicklistProperty(CrmStr.incomingemailfilteringmethod,value);
			}
		}

        public string incomingemailfilteringmethodLabel
        {
            get
            {
                if ( ContainsKey(CrmStr.incomingemailfilteringmethod) )
                    return PicklistPropertyLabelValue(CrmStr.incomingemailfilteringmethod);
                return string.Empty;
            }
        }
        
        /// <summary>
        /// Gets or sets whether a queue is the fax delivery queue. 
        /// </summary>
        [CrmDynAttribute(CrmStr.queue)]
        public bool isfaxqueue
        {
            get 
            {
                return BooleanPropertyValue(CrmStr.isfaxqueue);
            }
            set 
            {
                AddBooleanProperty(CrmStr.isfaxqueue,value);
            }
        }


        /// <summary>
        /// Gets or sets the outgoing e-mail delivery method for the queue. 
        /// None 
        /// E-mail Router
        /// </summary>
        [CrmDynAttribute(CrmStr.queue)]
        public int outgoingemaildeliverymethod
		{
			get
			{
				return PicklistPropertyIntValue(CrmStr.outgoingemaildeliverymethod);
			}
			set
			{
				AddPicklistProperty(CrmStr.outgoingemaildeliverymethod,value);
			}
		}

        public string outgoingemaildeliverymethodLabel
        {
            get
            {
                if ( ContainsKey(CrmStr.outgoingemaildeliverymethod) )
                    return PicklistPropertyLabelValue(CrmStr.outgoingemaildeliverymethod);
                return string.Empty;
            }
        }
        
        /// <summary>
        /// Gets or sets the ID for the owner of the queue. 
        /// </summary>
        [CrmDynAttribute(CrmStr.queue)]
        public Guid primaryuserid
        {
           get
           {
                return LookupPropertyValue(CrmStr.primaryuserid);
           }
           set
           {
               AddLookupProperty(CrmStr.systemuser,CrmStr.primaryuserid,value);
           }
        }

        public string primaryuserName
        {
            get
            {
                if ( ContainsKey(CrmStr.primaryuserid) )
                    return LookupPropertyName(CrmStr.primaryuserid);
                return string.Empty;
            }
        }

        /// <summary>
        /// For internal use only. 
        /// </summary>
        [CrmDynAttribute(CrmStr.queue)]
        public int queuesemantics
        {
            get
            {
                if ( ContainsKey(CrmStr.queuesemantics) )
                    return NumberPropertyValue(CrmStr.queuesemantics);
                return 0;
            }
            set
            {
                AddNumberProperty(CrmStr.queuesemantics,value);
            }
        }

        /// <summary>
        /// Gets the type of queue that is automatically assigned when a user or queue is created. 
        /// The type can be public, private, or work in process. 
        /// </summary>
        [CrmDynAttribute(CrmStr.queue)]
        public int queuetypecode
		{
			get
			{
				return PicklistPropertyIntValue(CrmStr.queuetypecode);
			}
			set
			{
				AddPicklistProperty(CrmStr.queuetypecode,value);
			}
		}

        public string queuetypecodeLabel
        {
            get
            {
                if ( ContainsKey(CrmStr.queuetypecode) )
                    return PicklistPropertyLabelValue(CrmStr.queuetypecode);
                return string.Empty;
            }
        }
        
        /// <summary>
        /// Gets the ID of the organization associated with the queue
        /// </summary>
        [CrmDynAttribute(CrmStr.queue)]
        public override Guid organizationid
        {
            get
            {
                if ( ContainsKey(CrmStr.organizationid) )
                    return LookupPropertyValue(CrmStr.organizationid);
                return Guid.Empty;
            }
        }

        public override string organizationName
        {
            get
            {
                if ( ContainsKey(CrmStr.organizationid) )
                    return LookupPropertyName(CrmStr.organizationid);
                return string.Empty;
            }
        }

        [CrmDynAttribute(CrmStr.queue)]
   		public Guid businessunitid
        {
            get
            {
				return LookupPropertyValue(CrmStr.businessunitid);
            }
            set
            {
                AddLookupProperty(CrmStr.businessunitid,CrmStr.businessunit,value);
            }
        }

        [CrmDynAttribute(CrmStr.queue)]
   		public string businessunitName
        {
            get
            {
                if ( ContainsKey(CrmStr.businessunitid) )
				    return LookupPropertyName(CrmStr.businessunitid);
                return string.Empty;
            }
        }
    }
}
